<?php

/*
  This model provides all interfaces for user management
 */

class Languages_model extends CI_Model {

    public function getLanguageById($id) {
        $this->db->select("*");
        $this->db->from("languages");
        $this->db->where('language_id', $id);

        $query = $this->db->get();
        $result = $query->result();
        return !empty($result) ? $result[0] : array();
    }

    public function getLanguages($data = array()) {
        $this->db->select("*");
        $this->db->from("languages");
        $this->db->order_by("sort_order", "asc");
        $query = $this->db->get();
        $results = $query->result();

        return $results;
    }

    public function insert($data) {
        $this->db->insert('languages', $data);
        return $this->db->insert_id();
    }

    public function update($id, $data) {
        $this->db->where('language_id', $id);
        return $this->db->update('languages', $data);
    }

}